package weeny.pre.expression;

import prefuse.data.Tuple;
import prefuse.util.ColorLib;

/**
 * Get the alpha value of a color (suppose the parameter is a column name which
 * indicating some color attribute)
 * 
 * @author weeny
 */
public class AlphaFunction extends IntFunction{
	public AlphaFunction() {
		super(1);
	}
	@Override
	public String getName() {
		return "ALPHA";
	}
	@Override
	public int getInt(Tuple t) {
        if ( paramCount() == 1 ) {
        	//param(0) should be a column expression
        	//and indicating some color
            return ColorLib.alpha(param(0).getInt(t));
        } else {
            missingParams(); return 0;
        }
	}
}
